package mains;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

public class Main6JoinExample {

    private static final String PERSISTENCE_UNIT_NAME = "CashM";
    private static EntityManagerFactory factory;

    public static void main(String[] args) {
	factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
	EntityManager em = factory.createEntityManager();

	TypedQuery<String> query = em
		.createQuery(
			"SELECT c.name FROM Payment p, Customer c WHERE c.id = p.customerId AND p.total > 500.0",
			String.class);
	List<String> listM = null;
	try {
	    listM = query.getResultList();
	} finally {
	    em.close();
	}
	if (listM != null) {
	    for (String s : listM) {
		System.out.println(s);
	    }
	}

    }

}
